import { ConditionList } from "~/search.match";

import { getGateway, Gateway } from "@/droplet-bus/core.define";
import { BookQuery } from "@/pond-book/core.define";

import { RiverTonGateway } from "@/river-ton/core.define";
import { TonOrder, TonOrderGroup } from "@/river-ton/schema.order";

export const TonOrderBookStatGateway: Gateway = getGateway(RiverTonGateway, "river_ton_order_book_stat");

/** 先搜索订单，再统计订单指定的明细账 */
export type getTonOrderBookStatDto = {
  conditionList: ConditionList<TonOrder>;
  groupId: TonOrderGroup["id"];
  query: BookQuery[];
};

export interface TonOrderBookStatInterfaceWithGrant<T> {
  /** 例如：在订单的左下角，显示：销售额 还应收款 已开发票是多少 */
  getTonOrderBookStat(dto: T & getTonOrderBookStatDto): Promise<(BookQuery & { total: number })[]>;
}
